package com.ruoyi.web.controller.combat.useralignment;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.combat.domain.useralignment.CombatBlogWb;
import com.ruoyi.combat.service.useralignment.ICombatBlogWbService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课题五微博用户发布内容Controller
 * 
 * @author ruoyi
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/combat/blogWb")
public class CombatBlogWbController extends BaseController
{
    @Autowired
    private ICombatBlogWbService combatBlogWbService;

    /**
     * 查询课题五微博用户发布内容列表
     */
    @PreAuthorize("@ss.hasPermi('combat:blogWb:list')")
    @GetMapping("/list")
    public TableDataInfo list(CombatBlogWb combatBlogWb)
    {
        startPage();
        List<CombatBlogWb> list = combatBlogWbService.selectCombatBlogWbList(combatBlogWb);
        return getDataTable(list);
    }

    /**
     * 导出课题五微博用户发布内容列表
     */
    @PreAuthorize("@ss.hasPermi('combat:blogWb:export')")
    @Log(title = "课题五微博用户发布内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CombatBlogWb combatBlogWb)
    {
        List<CombatBlogWb> list = combatBlogWbService.selectCombatBlogWbList(combatBlogWb);
        ExcelUtil<CombatBlogWb> util = new ExcelUtil<CombatBlogWb>(CombatBlogWb.class);
        util.exportExcel(response, list, "课题五微博用户发布内容数据");
    }

    /**
     * 获取课题五微博用户发布内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('combat:blogWb:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(combatBlogWbService.selectCombatBlogWbById(id));
    }

    /**
     * 新增课题五微博用户发布内容
     */
    @PreAuthorize("@ss.hasPermi('combat:blogWb:add')")
    @Log(title = "课题五微博用户发布内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CombatBlogWb combatBlogWb)
    {
        return toAjax(combatBlogWbService.insertCombatBlogWb(combatBlogWb));
    }

    /**
     * 修改课题五微博用户发布内容
     */
    @PreAuthorize("@ss.hasPermi('combat:blogWb:edit')")
    @Log(title = "课题五微博用户发布内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CombatBlogWb combatBlogWb)
    {
        return toAjax(combatBlogWbService.updateCombatBlogWb(combatBlogWb));
    }

    /**
     * 删除课题五微博用户发布内容
     */
    @PreAuthorize("@ss.hasPermi('combat:blogWb:remove')")
    @Log(title = "课题五微博用户发布内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(combatBlogWbService.deleteCombatBlogWbByIds(ids));
    }


    /**
     * 发文趋势统计
     * @return
     */
    @ApiOperation(value = "根据用户id查看用户的发文趋势统计")
    @GetMapping(value = "/sendStatistics")
    public AjaxResult sendStatistics(String userId) {
        return AjaxResult.success(combatBlogWbService.sendStatistics(userId));
    }
    /**
     * 数量统计
     * @return
     */
    @ApiOperation(value = "数量统计")
    @GetMapping(value = "/numberStatistics")
    public AjaxResult numberStatistics(String userId) {
        return AjaxResult.success(combatBlogWbService.numberStatistics(userId));
    }
}
